using SumerCoreDevOps.Shared.Enums;

namespace SumerCoreDevOps.Shared.Models.Messages;

/// <summary>
/// 消息转发请求（用于主节点间的消息转发）
/// </summary>
public class MessageForwardRequest
{
    /// <summary>
    /// 目标节点ID
    /// </summary>
    public long TargetNodeId { get; set; }

    /// <summary>
    /// 消息类型
    /// </summary>
    public TcpMessageType MessageType { get; set; }

    /// <summary>
    /// 消息负载（JSON序列化）
    /// </summary>
    public string Payload { get; set; } = string.Empty;

    /// <summary>
    /// 源主节点ID
    /// </summary>
    public string SourceMasterId { get; set; } = string.Empty;

    /// <summary>
    /// 转发时间戳
    /// </summary>
    public DateTime Timestamp { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 消息ID（用于追踪）
    /// </summary>
    public string MessageId { get; set; } = Guid.NewGuid().ToString("N");
}

/// <summary>
/// 消息转发响应
/// </summary>
public class MessageForwardResponse
{
    /// <summary>
    /// 消息ID
    /// </summary>
    public string MessageId { get; set; } = string.Empty;

    /// <summary>
    /// 是否成功
    /// </summary>
    public bool Success { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string? ErrorMessage { get; set; }

    /// <summary>
    /// 处理的主节点ID
    /// </summary>
    public string ProcessedByMasterId { get; set; } = string.Empty;
}
